class Solution
{
public:
    int numTimesAllBlue(vector<int> &flips)
    {
        int maxFlipIndex = 0;
        int n = flips.size();
        int count = 0;
        for (int i = 1; i <= n; ++i)
        {
            maxFlipIndex = max(maxFlipIndex, flips[i - 1]);
            if (maxFlipIndex == i)
            {
                ++count;
            }
        }
        return count;
    }
};